package com.nari.kmd_dataservice.controller;

import com.nari.kmd_dataservice.jwt.UserLoginToken;
import com.nari.kmd_dataservice.service.impl.ServerServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @ClassName: ServerController
 * @Description:
 * @Author: zhangnaijiang
 * @Date: 2022/01/22 02:01
 * @Version 1.0.0
 */
@RestController
@RequestMapping(value = "/server")
@Api(value = "需求响应服务", tags = "需求响应服务")
@Slf4j
public class ServerController {

    @Autowired
    private ServerServiceImpl serverService;

    //{ "registRationId":null, "userName":"account001", "password":"123456", "laName":"聚合商名称", "url":"127.0.0.1:443", "data":[ { "consNo":"consNo001", "peakAblity": 11.11, "vallyAblity":22.22, "powerType":"001", "responseLevel":"001"} ] }
    @PostMapping(value = "/laRegister")
    @ApiOperation(value = "负荷聚合平台认证注册", notes = "用于负荷聚合平台认证注册")
    public String laRegister(@RequestBody String jsonParameter) {
        log.info("负荷聚合平台认证注册{}", jsonParameter);
        return serverService.laRegister(jsonParameter);
    }

    //{"registRationId":"registRationId001", "data":[ { "updateStatus":"01", "consNo":"consNo001", "peakAbility": 11.11, "vallyAbility":22.22, "powerType":"001", "responseLevel":"001" }] }
    @PostMapping(value = "/reportResource")
    @UserLoginToken
    @ApiOperation(value = "负荷聚合平台上报资源信息", notes = "用于负荷聚合平台上报资源信息")
    public String reportResource(@RequestBody String jsonParameter) {
        log.info("负荷聚合平台上报资源信息{}", jsonParameter);
        return serverService.reportResource(jsonParameter);
    }

    //{"status":"01","responseUsers":[{"consNo":"consNo001","isSuccess":"01"},{"consNo":"consNo002","isSuccess":"01"}]}
    @PostMapping(value = "/targetResponseCons")
    @UserLoginToken
    @ApiOperation(value = "负荷聚合平台上报事件响应用户", notes = "用于负荷聚合平台上报事件响应用户")
    public String targetResponseCons(@RequestBody String jsonParameter) {
        log.info("负荷聚合平台上报事件响应用户{}", jsonParameter);
        return serverService.targetResponseCons(jsonParameter);
    }

    //{"registRationId":"registRationId001"}
    @PostMapping(value = "/responseCons")
    @UserLoginToken
    @ApiOperation(value = "负荷聚合平台获取可响应用户信息", notes = "用于负荷聚合平台获取可响应用户信息")
    public String responseCons(@RequestBody String jsonParameter) {
        log.info("负荷聚合平台获取可响应用户信息{}", jsonParameter);
        return serverService.responseCons(jsonParameter);
    }

    //{ "registRationId":"registRationId001", "eventId":"eventId001" }
    @PostMapping(value = "/targetHistory")
    @UserLoginToken
    @ApiOperation(value = "负荷聚合平台查询事件响应结果", notes = "用于负荷聚合平台查询事件响应结果")
    public String targetHistory(@RequestBody String jsonParameter) {
        log.info("负荷聚合平台查询事件响应结果{}", jsonParameter);
        return serverService.targetHistory(jsonParameter);
    }

    //{"registRationId":"registRationId001", "data":[{"CONS_NO":"consNo001", "CONS_NAME":"用户名称001"}, {"CONS_NO":"consNo002", "CONS_NAME":"用户名称002"} ] }
    @PostMapping(value = "/upLoadUserInfo")
    @UserLoginToken
    @ApiOperation(value = "户号验证", notes = "户号验证")
    public String upLoadUserInfo(@RequestBody String jsonParameter) {
        log.info("户号验证{}", jsonParameter);
        return serverService.upLoadUserInfo(jsonParameter);
    }

}
